"use strict";

const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
  entry: {
    index: "./src/index.js",
    app: "./src/app.js",
  },
  output: {
    path: path.join(__dirname, "zdist"),
    filename: "[name].js",
  },
  mode: "production",
  plugins: [
    new CleanWebpackPlugin({ verbose: true }),
    new HtmlWebpackPlugin({
      template: "./src/index.html",
      chunks: ['index'],
      filename:'index.html',
      scriptLoading: "blocking",
    }),
    new HtmlWebpackPlugin({
      template: "./src/index.html",
      chunks: ['app'],
      filename:'app.html',
      scriptLoading: "blocking",
    }),
  ],
  optimization:{
    splitChunks:{
      chunks:'all',
      cacheGroups:{
        default:false,
        defaultVendors: {
          idHint: "vendors",
          reuseExistingChunk: true,
          test: /[\\/]node_modules[\\/]/i
        }
      }
    }
  }
};
